import React, { Component } from 'react';
import Script from 'next/script';

// https://www.nextjs.cn/docs/basic-features/script


class Comp extends Component {
  componentDidMount = () => {};
  render() {
    return (
      <div>
        Script的使用

        {/* <Script
          src="https://unpkg.com/loadjs@4.3.0-rc1/dist/loadjs.min.js"
          strategy="beforeInteractive" //在页面交互之前加载
        /> */}

        <Script
          src="https://unpkg.com/loadjs@4.3.0-rc1/dist/loadjs.min.js"
          strategy="afterInteractive" //页面变为交互式后立即加载
          onLoad={() => {
            console.log('执行完了')
          }}
        />

        {/* <Script
          src="https://unpkg.com/loadjs@4.3.0-rc1/dist/loadjs.min.js"
          strategy="lazyOnload" //空闲时加载
        /> */}

        {/* 内联脚本 */}
        <Script id="script1" strategy="lazyOnload">
          {`console.log(document.body)`}
        </Script>
      </div>
    );
  }
}
export default Comp;
